package com.elastic.util;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

import org.elasticsearch.search.SearchHitField;

public class EsUtil {

	 public static void printMap(Map<String,Object> sourceMap){
			Set<Entry<String, Object>> entrys = sourceMap.entrySet();
			Iterator<Entry<String, Object>> its = entrys.iterator();
			while (its.hasNext()) {
				Entry<String, Object> tt = its.next();
				System.out
						.println("key=" + tt.getKey() + ",value=" + tt.getValue());
			}

			// 默认没有field
//			Map<String, GetField> map = response.getFields();
//			Set<String> set = map.keySet();
//			Iterator<String> ite = set.iterator();
//			while (ite.hasNext()) {
//				String s = ite.next();
//				System.out.println("key==" + s);
//				GetField t = map.get(s);
//				System.out.println(t.getName() + ",value==" + t.getValue());
//			}
		}
	 
	 public static void printMapFiled(Map<String,SearchHitField> sourceMap){
			Set<Entry<String, SearchHitField>> entrys = sourceMap.entrySet();
			Iterator<Entry<String, SearchHitField>> its = entrys.iterator();
			while (its.hasNext()) {
				Entry<String, SearchHitField> tt = its.next();
				String key = tt.getKey();
				SearchHitField fi = tt.getValue();
				String d = String.valueOf(fi.getValue());
				System.out.println("key="+key+",name="+fi.getName()+",value="+d);
			}
		}
}
